Technically you can death level a pet to your level +6, as it still gains XP when it is 5 levels above you.
Pets do gain XP even if above your level, but they will be gaining less per kill (if you solo kill a level 10 enemy at level 10 you gain 100 XP, but the pet would be slated for 64 according to theory) and require more per level (after all, we need more for higher levels). Additionally, they get no XP from quests and missions, nor do they benefit from hunts or scrolls.
|